﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// Reviewed

#pragma once

#include "ICurve.h"

namespace gcmp
{
    class Box2d;
    class Vector2d;

    /// \brief 二维曲线
    ///
    class ICurve2d : public ICurve
    {
        DEFINE_CAST_DERIVED(gcmp::ICurve2d, gcmp::ICurve);
    public:
        /// \brief  获取二维曲线的包围盒
        /// \return 二维包围盒
        virtual Box2d GetBox2d() const = 0;

        /// \brief  根据参数求二维曲线上的点
        /// \param parameter      参数
        /// \return 二维点
        virtual Vector2d GetPoint(double parameter) const = 0;

        /// \brief  获取二维曲线的起点-
        /// \return 二维曲线的起点
        virtual Vector2d GetStartPoint() const = 0;

        /// \brief  获取二维曲线的终点
        /// \return 终点
        virtual Vector2d GetEndPoint() const = 0;

        /// \brief  获取二维曲线的中点
        /// \return 中点
        virtual Vector2d GetMiddlePoint() const = 0;

        /// \brief  根据参数求二维曲线上的对应位置的切向
        /// \param parameter      参数
        /// \return 切向
        virtual Vector2d GetTangent(double parameter) const = 0;

        /// \brief  计算二维曲线起点的切向
        /// \return 起点的切向
        virtual Vector2d GetStartTangent() const = 0;

        /// \brief  计算二维曲线终点的切向
        /// \return 终点的切向
        virtual Vector2d GetEndTangent() const = 0;

        /// \brief 根据坐标点计算对应的参数值
        /// \param pointOnCurve      坐标点(在曲线上)
        /// \param distEpsilon             距离容差(参考值0.0001)
        /// \param pointParam             点在曲线上的参数
        /// \param isParamInLimit          求得的参数是否在曲线的参数区间内（true表示在，false表示不在）
        /// \return  点在二维曲线上（求得的参数对应的点和已知点得距离小于距离容差）返回True，否则返回false
        virtual bool GetParameter(const Vector2d &pointOnCurve, double &pointParam, bool &isParamInLimit, double distEpsilon) const = 0;


    public:
        virtual ~ICurve2d() {}
    };
}
